package com.study.hot.jetpack.startup

import android.content.ContentProvider
import android.content.ContentValues
import android.database.Cursor
import android.net.Uri
import com.study.hot.jetpack.startup.utils.MyGlobalUtils

/**
 * <pre>
 *     author : slx
 *     time   : 2020/11/24
 *     desc   : AndroidUtils 初始化
 * </pre>
 */
class InitContentProvider : ContentProvider() {

    override fun onCreate(): Boolean {
        context?.let {
            MyGlobalUtils.init(it.applicationContext)
        }
        return true
    }

    // 由于是专门用于初始化的CP，以下方法直接空实现或者抛出异常即可
    override fun query(
        uri: Uri,
        projection: Array<out String>?,
        selection: String?,
        selectionArgs: Array<out String>?,
        sortOrder: String?
    ): Cursor? {
        return null
    }

    override fun getType(uri: Uri): String? {
        return null
    }

    override fun insert(uri: Uri, values: ContentValues?): Uri? {
        return null
    }

    override fun delete(uri: Uri, selection: String?, selectionArgs: Array<out String>?): Int {
        return 0
    }

    override fun update(
        uri: Uri,
        values: ContentValues?,
        selection: String?,
        selectionArgs: Array<out String>?
    ): Int {
        return 0
    }
}